/**
*   \file   Box.h
*   \author Dave Reid
*   \brief  Header file for the Box class.
*/
#ifndef __EAGL_BOX_H_
#define __EAGL_BOX_H_

#include "../types.h"

namespace eagl
{

/**
*   \brief  Class representing a Box.
*
*   A Box is defined three extents - width, height and depth. The centre
*   point of the extents is considered the position of the Box.
*/
class Box
{
public:

    /**
    *   \brief  Default constructor.
    */
    Box() : m_extents(1.0f, 1.0f, 1.0f)
    {
    }

    /**
    *   \brief               Constructor.
    *   \param  extents [in] The extents of the Box.
    */
    Box(const vec3 &extents) : m_extents(extents)
    {
    }


    /**
    *   \brief  Retrieves the extents of the Box.
    *   \return The extents of the Box.
    */
    const vec3 & getExtents() const
    {
        return this->m_extents;
    }

    /**
    *   \brief               Sets the extents of the Box.
    *   \param  extents [in] The extents of the Box.
    */
    void setExtents(const vec3 &extents)
    {
        this->m_extents = extents;
    }

    /**
    *   \brief              Sets the extents of the Box.
    *   \param  width  [in] The new width of the Box.
    *   \param  height [in] The new height of the Box.
    *   \param  depth  [in] The new depth of the Box.
    */
    void setExtents(float width, float height, float depth)
    {
        this->m_extents.x = width;
        this->m_extents.y = height;
        this->m_extents.z = depth;
    }


    /**
    *   \brief  Retrieves the position of the Box.
    *   \return The position of the Box.
    */
    vec3 getPosition() const
    {
        return vec3(this->m_transformation[0][3],
                    this->m_transformation[1][3],
                    this->m_transformation[2][3]);
    }

    /**
    *   \brief           Sets the position of the Box.
    *   \param  pos [in] The new position of the Box.
    */
    void setPosition(const vec3 &pos)
    {
        this->m_transformation[0][3] = pos.x;
        this->m_transformation[1][3] = pos.y;
        this->m_transformation[2][3] = pos.z;
    }


private:

    /// The extents of the Box. This is essentially the width, height and depth of the Box.
    vec3 m_extents;

    /// The transformation of the Box.
    eagl::mat4 m_transformation;
};

}


#endif  // __EAGL_BOX_H_